//
//  WZOutFrame.m
//  ETong
//
//  Created by wanzhao on 15/11/24.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZOutFrame.h"
#define fileWidth [UIImage imageNamed:@"outNormalFile"].size.width

@implementation WZOutFrame

- (void)setWzOut:(WZOut *)wzOut
{
    _wzOut = wzOut;
    _outFileFrame = CGRectMake(OppositeWidthRate(10), 0, fileWidth, 0);
    CGSize maxSize = CGSizeMake(HARDWARE_SCREEN_WIDTH - OppositeWidthRate(60) - fileWidth, MAXFLOAT);
    
    //计算申请时间的frame
    CGSize timeSize = [[NSString stringWithFormat:@"申请外出时间 %@",wzOut.planBeginTime] sizeWithFont:Font12 maxSize:maxSize];
    _outApplyTimeFrame = CGRectMake(CGRectGetMaxX(_outFileFrame) + OppositeWidthRate(5), OppositeHeightRate(10), timeSize.width, timeSize.height);
    
    //计算申请公司的frame
    timeSize = [wzOut.customerName sizeWithFont:Font14 maxSize:maxSize];
    _outCompanyFrame = CGRectMake(_outApplyTimeFrame.origin.x, CGRectGetMaxY(_outApplyTimeFrame) + OppositeHeightRate(5), timeSize.width, timeSize.height);
    //计算申请地址的frame
    timeSize = [[NSString stringWithFormat:@"地址：%@",wzOut.outAddress] sizeWithFont:Font12 maxSize:maxSize];
    _outApplyAddressFrame = CGRectMake(_outApplyTimeFrame.origin.x, CGRectGetMaxY(_outCompanyFrame) + OppositeHeightRate(5), timeSize.width, timeSize.height);
    
    //计算背景的frame
    _outBgFrame = CGRectMake(OppositeWidthRate(10), 0, HARDWARE_SCREEN_WIDTH - OppositeWidthRate(20), CGRectGetMaxY(_outApplyAddressFrame) + OppositeHeightRate(10));
    
    /**距离frame*/
    _distanceFrame = CGRectMake(CGRectGetMaxX(_outBgFrame) - OppositeWidthRate(75), CGRectGetMinY(_outApplyTimeFrame), OppositeWidthRate(75), timeSize.height);
    
    //计算file的frame
    _outFileFrame = CGRectMake(OppositeWidthRate(10), 0, fileWidth, _outBgFrame.size.height);
    //计算cell的高度
    _cellHeight = CGRectGetMaxY(_outBgFrame) + OppositeHeightRate(5);

}

@end
